package com.puppet.building182.mapper;

import com.puppet.building182.pojo.VO.RoleVo;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@Mapper
public interface RoleMapper {

    @Select("SELECT sys_role.id,sys_role.role_name,sys_role.role_code FROM sys_role")
    List<RoleVo> getAllRole();

    @Select("select*from  sys_role_user where user_id=#{id}")
    List<RoleVo> getRolesByUid(Integer id);

    @Delete("delete from sys_role_user where user_id=#{uid}")
    Integer deleteRoleByUid(Integer uid);

    Integer saveNewRoles(@Param("uid") Integer uid, @Param("ids") List<Integer> roleIds);

    @Select("SELECT COUNT(*) FROM `sys_role_user` WHERE user_id")
    Integer countRoleByUserId();

    @Update("update sys_role set role_name=#{roleName},role_code=#{roleCode} where id=#{id}")
    Integer updateRole(RoleVo roleVo);

    @Select("select*from sys_role where id=#{id}")
    RoleVo getrolebyid(Integer id);

    @Delete("delete from sys_role where id=#{id}")
    Integer deleteRoleById(Integer id);
}
